﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EETOP.OAuthSDK;
using System.Configuration;

namespace SDKTEST
{
    public partial class _Default : System.Web.UI.Page
    {
        static AbleAPI able;

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {

                OAuthSettings setting = OAuthSettings.Create(
                   new EndPoint(ConfigurationManager.AppSettings["request_token_address"]),
                   new Uri(ConfigurationManager.AppSettings["authorize_address"]),
                   new EndPoint(ConfigurationManager.AppSettings["access_token_address"]),
                   Request.Url,
                   new OAuthConsumer(ConfigurationManager.AppSettings["app_key"],
                   ConfigurationManager.AppSettings["app_secret"])
                   );
                able = new AbleAPI(setting);
                
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string result = "";

            switch (int.Parse(DropDownList1.SelectedValue))
            {
                case 0: result = able.GetUserInfo();
                    break;
                case 1: result = able.IsAuthorized();
                    break;
                case 2: result = able.GetMyComs();
                    break;
                case 3: result = able.MyColleagues("b130c071-d2cf-4e2d-baf3-81e839042a0e");
                    break;
                default: break;
            }
            TextBox1.Text = result;
        }
    }
}
